<?php
/**
 * Yii view import
 *
 * @author nguyenmanhluu
 * @since Aug 28, 2013 - 2:41:07 PM
 */
?>
<div class="box span12">
    <div class="box-header">
        <h2>
            <i class="icon-envelope"></i>
            Import Customer from CSV
        </h2>
    </div>
    <div class="box-content">
        <?php if (Yii::app()->user->hasFlash('success')): ?>
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <?php echo Yii::app()->user->getFlash('success'); ?>
            </div>
        <?php elseif (Yii::app()->user->hasFlash('error')): ?>
            <div class="alert alert-error">
                <button type="button" class="close" data-dismiss="alert">×</button>
                <?php echo Yii::app()->user->getFlash('error'); ?>
            </div>
        <?php endif; ?>        
        <div class="row-fluid">
            <div class="span6">
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id'                     => 'import-form',
                    'enableClientValidation' => true,
                    'htmlOptions'            => array(
                        'class'   => 'form-horizontal',
                        'enctype' => 'multipart/form-data',
                    ),
                    'clientOptions'          => array(
                        'validateOnSubmit' => true,
                    ),
                ));
                ?>                
                <fieldset>
                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'file', array('class' => 'control-label')); ?>                            
                        <div class ="controls">
                            <?php echo $form->fileField($model, 'file'); ?>                                
                            <font color="red"> <?php echo $form->error($model, 'default_password'); ?> </font>
                            <br/>
                            <br/>
                            <div>
                                <a class="btn btn-primary" href="<?php echo $this->assetDir ?>csv/customer_template.csv">
                                    Download CSV template file
                                </a>
                            </div>                                
                        </div>
                    </div>

                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'default_password', array('class' => 'control-label')); ?>                            
                        <div class ="controls">
                            <?php echo $form->textField($model, 'default_password'); ?>                                
                            <p>Default password for customer using after import</p>
                            <font color="red"> <?php echo $form->error($model, 'default_password'); ?> </font>
                        </div>
                    </div>                        
                    <?php if (Yii::app()->controller->isAdmin): ?>
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'biz_id', array('class' => 'control-label')); ?>
                            <div class ="controls">                                                   
                                <?php echo $form->dropDownList($model, 'biz_id', Users::getAllBussiness()); ?>
                                <font color="red"> <?php echo $form->error($model, 'biz_id'); ?> </font>
                            </div>
                        </div>
                    <?php endif; ?>

                    <div class="control-group">                    
                        <div class ="controls">
                            <button class="btn btn-primary">Save</button>
                        </div>
                    </div> 
                </fieldset>
                <?php $this->endWidget(); ?>
            </div>
            <?php if (!empty($resultArray)): ?>
                <div class="span6">
                    <?php foreach ($resultArray as $email => $status): ?>
                        <div class="alert alert-info">
                            <button type="button" class="close" data-dismiss="alert">×</button>
                            <strong><?php echo $email ?></strong>
                            <?php echo $status ?>
                        </div>
                    <?php endforeach; ?>
                </div>

            <?php endif; ?>
        </div>
    </div>
</div>
